1 Transects

Plant Flowers Date lon lat ele
Glossoloma oblongicalyx 4 2015-10-19 -78.59093 0.130838 2270
Gasteranthus quitensis 2 2016-10-17 -78.59770 0.120070 1940
Kohleria affinis 1 2016-12-13 -78.59534 0.126746 2110
Columnea ciliata 3 2014-02-27 -78.59934 0.116682 1960
Columnea medicinalis 1 2014-04-23 -78.59372 0.128700 2130
Drymonia teuscheri 3 2016-07-28 -78.59245 0.129393 2200

2 Interactions

2.1 Species elevation ranges

2.2 Flowering Data Matrix

3 Are flowering patterns non-random with respect hummingbird overlap and elevation?

Let’s start with a traditional randomization test to get everyone comfortable with the essential result. For each random draw, calculate the mean niche overlap in hummingbird usage. Species can only bloom at site which they occur. Mantains plant abundance.

3.1 Prepare data for JAGS

4 Species Identity

Equal probability of flowering at anytime.

## sink("model/threshold_baseline.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <- alpha[Plant[x]] 
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #predict value
##     
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-alpha[PredPlant[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##     
##     #Intercept flowering probability
##     alpha[j] ~ dnorm(0,0.386)
##     
##     } 
## 
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2955
##    Unobserved stochastic nodes: 3690
##    Total graph size: 17039
## 
## Initializing model

5 Get Chains

5.0.1 Evaluate convergence

5.0.2 Posterior estimates

6 Species Identity + Site

Equal probability of flowering per elevation

## sink("model/threshold_baseline_site.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <- alpha[Plant[x],Site[x]] 
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-alpha[NewPlant[x],NewSite[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #Priors
##     
##     #Species level priors
##     for (i in 1:Plants){
##     for(j in 1:Sites){
##     
##     #Intercept flowering probability
##     alpha[i,j] ~ dnorm(0,0.386)
##     
##     } 
##     }
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2955
##    Unobserved stochastic nodes: 3765
##    Total graph size: 21091
## 
## Initializing model

7 Get Chains

7.0.1 Evaluate convergence

7.0.2 Posterior estimates

8 Species Identity + Site + Month

Equal probability of flowering per elevation

## sink("model/threshold_baseline_site_month.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <- alpha[Plant[x],Site[x],Month[x]] 
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-alpha[NewPlant[x],NewSite[x],NewMonth[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #Priors
##     
##     #Species level priors
##     for (i in 1:Plants){
##       sigma_month[i] ~ dgamma(0.0001,0.0001)
##     for(j in 1:Sites){
##       alpha_site[i,j] ~ dnorm(0,0.386)
##     for(k in 1:Months){
##     #Intercept flowering probability
##       alpha[i,j,k] ~ dnorm(alpha_site[i,j],sigma_month[i])
##     }
##     } 
##     }
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2955
##    Unobserved stochastic nodes: 4860
##    Total graph size: 29213
## 
## Initializing model

9 Get Chains

9.0.1 Evaluate convergence

9.0.2 Posterior estimates

10 Predictive Models of Co-Flowering

10.1 Visitor Attraction

11 Get Chains

11.1 Attraction

## sink("model/threshold_attraction.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <-  alpha[Plant[x],Site[x]] + e[Plant[x],Site[x],Month[x]]
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #predict value
##     
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<- alpha[NewPlant[x],NewSite[x]] + e[NewPlant[x],NewSite[x],NewMonth[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
##     
##     #For each of observation
##     for(y in 1:Sites){
##     for(x in 1:Months){
##     e[1:Plants,y,x] ~ dmnorm(zeros,tauC[,])
##     }
##     }
## 
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=inverse(vCov*gamma)
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##       for(k in 1:Sites){
##       #Intercept flowering probability
##       alpha[j,k] ~ dnorm(0,0.386)
##     } }
## 
##     #Autocorrelation priors
##     gamma  ~ dunif(0,5)
##     
##     #Strength of covariance decay
##     lambda_cov ~ dunif(0,5)
##     omega = 1
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2955
##    Unobserved stochastic nodes: 3839
##    Total graph size: 31040
## 
## Initializing model

11.1.1 Evaluate convergence

11.1.2 Posterior estimates

11.2 Effect of interaction attraction

11.3 Repulsion

## sink("model/threshold_repulsion.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
##     
##     #Observation of a flowering plant
##     Y[x] ~ dbern(p[x])
##     logit(p[x]) <-  alpha[Plant[x],Site[x]] + e[Plant[x],Site[x],Month[x]]
##     
##     #Residuals
##     discrepancy[x] <- abs(Y[x] - p[x])
##     
##     #Assess Model Fit
##     Ynew[x] ~ dbern(p[x])
##     discrepancy.new[x]<-abs(Ynew[x] - p[x])
##     }
##     
##     
##     #Sum discrepancy
##     fit<-sum(discrepancy)/Nobs
##     fitnew<-sum(discrepancy.new)/Nobs
##     
##     #Prediction
##     
##     for(x in 1:Npreds){
##     #predict value
##     
##     #Observation - probability of flowering
##     prediction[x] ~ dbern(p_new[x])
##     logit(p_new[x])<-  alpha[NewPlant[x],NewSite[x]] + e[NewPlant[x],NewSite[x],NewMonth[x]]
##     
##     #predictive error
##     pred_error[x] <- abs(Ypred[x] - p_new[x])
##     }
##     
##     #Predictive Error
##     fitpred<-sum(pred_error)/Npreds
##     
##     #########################
##     #autocorrelation in error
##     #########################
##     
##     #For each of observation
##     for(x in 1:Months){
##     for(y in 1:Sites){
##     e[1:Plants,y,x] ~ dmnorm(zeros,tauC[,])
##     }
##     }
##     ##covariance among similiar species
##     for(i in 1:Plants){
##     for(j in 1:Plants){
##     C[i,j] = exp(-lambda_cov * D[i,j])
##     }
##     }
##     
##     ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
##     vCov = omega*C[,] + (1-omega) * I
##     tauC=vCov*gamma
##     
##     #Priors
##     
##     #Species level priors
##     
##     for (j in 1:Plants){
##       for(k in 1:Sites){
##       #Intercept flowering probability
##       alpha[j,k] ~ dnorm(0,0.386)
##       }
##     } 
## 
##     #Autocorrelation priors
##     gamma ~ dunif(0,5)
##     
##     #Strength of covariance decay
##     lambda_cov ~ dunif(0,5)
##     omega  = 1
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 2955
##    Unobserved stochastic nodes: 3839
##    Total graph size: 31039
## 
## Initializing model

12 Get Chains

12.0.1 Evaluate convergence

12.0.2 Posterior estimates

12.1 Effect of interaction repulsion

13 Model Comparison

13.0.1 E: The effect of autocorrelation

14 P(Flowering)

# One example

Glossoloma purpureum

14.1 Alpha: Species specific flowering rate

14.2 Omega: The magnitude of the effect of autocorrelation on mean flowering occurrence

14.3 Gamma: The variance of the effect of autocorrelation on mean flowering occurrence

14.4 Lambda: The decay in autocorrelation effect

14.5 Decay in autocorrelation effect

15 Model Fit

15.1 Bayesian pvalue

## # A tibble: 5 x 2
##   Model                      p
##   <chr>                  <dbl>
## 1 baseline               0.581
## 2 baseline_site          1    
## 3 baseline_site_month    1    
## 4 interaction_attraction 0.954
## 5 interaction_repulsion  1

Without baseline

## # A tibble: 4 x 2
##   Model                      p
##   <chr>                  <dbl>
## 1 baseline_site          1    
## 2 baseline_site_month    1    
## 3 interaction_attraction 0.954
## 4 interaction_repulsion  1

15.2 Model Fit

Model mean lower upper
baseline_site 0.2024240 0.1966618 0.2085226
baseline_site_month 0.1812022 0.1748977 0.1879261
interaction_repulsion 0.1802629 0.1729516 0.1875285
interaction_attraction 0.1635137 0.1556679 0.1721435

15.2.1 Without baseline

15.3 By Species

15.3.1 Without baseline

15.3.2 Zoom in

16 Prediction

16.1 Example from Glossoloma oblongicalyx

16.1.1 Tables

Model mean lower upper
baseline 0.2307659 0.2233611 0.2383207
baseline_site 0.2091269 0.2021064 0.2163815
interaction_repulsion 0.2001106 0.1918258 0.2083883
baseline_site_month 0.1997268 0.1930772 0.2067666
interaction_attraction 0.1950932 0.1856461 0.2049374

17 Flowering correlations in predictions

18 Example

Columnea medicinialis v Columnea strigosa which have strong overlap in visitors

Dint["Columnea medicinalis","Columnea strigosa"]
## [1] 0.2096899

Logit E

inv.logit E

## # A tibble: 2 x 4
## # Groups:   Model [2]
##   Model                  Var1                 Var2           Correlation_E
##   <chr>                  <fct>                <fct>                  <dbl>
## 1 interaction_attraction Columnea medicinalis Columnea stri…         0.966
## 2 interaction_repulsion  Columnea medicinalis Columnea stri…        -0.568
## # A tibble: 5 x 4
## # Groups:   Model [5]
##   Model                  Var1                 Var2           Correlation_P
##   <chr>                  <fct>                <fct>                  <dbl>
## 1 baseline               Columnea medicinalis Columnea stri…       NA     
## 2 baseline_site          Columnea medicinalis Columnea stri…        0.121 
## 3 baseline_site_month    Columnea medicinalis Columnea stri…       -0.0107
## 4 interaction_attraction Columnea medicinalis Columnea stri…        0.137 
## 5 interaction_repulsion  Columnea medicinalis Columnea stri…        0.118
## # A tibble: 5 x 4
## # Groups:   Model [5]
##   Model                  Var1                 Var2        Correlation_Ynew
##   <chr>                  <fct>                <fct>                  <dbl>
## 1 baseline               Columnea medicinalis Columnea s…          NA     
## 2 baseline_site          Columnea medicinalis Columnea s…           0.121 
## 3 baseline_site_month    Columnea medicinalis Columnea s…          -0.102 
## 4 interaction_attraction Columnea medicinalis Columnea s…           0.0446
## 5 interaction_repulsion  Columnea medicinalis Columnea s…           0.158

19 Figures for the paper

20 Figure 1

Flowering patterns

21 Example Flowering patterns

22 Figure 4

Model Fit and Prediction Fit

23 Predictions from the baseline models

Comparison of the attraction and repulsion

23.1 For a given site

23.1.1 5

Predictions from the best model

Supplamental figures